<!DOCTYPE html>
<html>

<head>
<title>添加代理</title>
<meta http-equiv="Pragma" CONTENT="no-cache">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="renderer" content="webkit">

<%include("/common/include.html"){}%>
<link rel="stylesheet" href="${cxt!}/sb/plugins/ztree/css/zTreeStyle/zTreeStyle.css" type="text/css">
<style type="text/css">
	.required{
			display:inline-block;
			width: 30%;
		}
		label{
			text-align:right;
			width:70px;
			display:inline-block;
		}
</style>
</head>

<body>
	<div class="easyui-panel" style="width: 100%; padding: 30px 60px; border-width: 0px;">
		<div style="margin:auto;width:760px">
			<form id="addDept" method="post" class="form">
				<div style="margin-bottom: 20px">
					<label class="label-top">所属部门:</label>
					<div class="required">
						<input class="easyui-textbox theme-textbox-radius" style="width: 100%;" value="${user.department.name! }" data-options="disabled:true">
					</div>
					<span style="color:red">*必填项</span>
					<input type="hidden"  value="${dept.ids! }" />
					<input type="hidden"  name="user.ids" value="${user.ids! }" />
			<% if(flag == '0'){ %>
								
							
					<label class="label-top" style="margin-left:30px">所属岗位:</label>
					<input id="citySel" type="text" readonly style="width: 218px; height: 32.4px;padding-left:10px;border-radius:4px;" onclick="showMenu(); return false;" class="textbox" value="${user.station.name! }"/>
					<span style="color:red">*必填项</span>
					<input id="stationids" type="hidden" name="user.stationids" value="${user.stationids! }">
			<% } %>	
				</div>
				<div style="margin-bottom: 20px">
					<label class="label-top">姓名:</label>
					<div class="required">
						<input class="easyui-textbox theme-textbox-radius" style="width: 100%;" name="user.name" value="${user.name! }">
					</div>
					<span style="color:red">*必填项</span>
					<label class="label-top" style="margin-left:30px">用户名:</label>
					<div class="required">
						<input class="easyui-textbox theme-textbox-radius" style="width: 100%;" name="user.username" value="${user.username! }">
					</div>
					<span style="color:red">*必填项</span>
				</div>
				<div style="margin-bottom: 20px">
				<label class="label-top">电话:</label>
				<div class="required">
					<input class="easyui-textbox theme-textbox-radius" style="width: 100%;" name="user.mobile" value="${user.mobile! }">
				</div>
				<span style="color:red">*必填项</span>
				
				<% if(organ.levelnum==2||organ.levelnum==0||organ.levelnum==1){ %>
				<% if(flag == '0'){ %>
				<label class="label-top" style="margin-left:30px">状态:</label>
				<div class="required">
					<select id = "status" style="width: 100%;height: 32.4px;" onclick="DisplayAndHiddenBtn()"class="easyui-combobox theme-textbox-radius" name="user.status">
						<option value="0"  
							<% if(user.status! == '0'){ %>
								selected="selected"
							<% } %>
						>禁用</option>
						<option value="1"  
							<% if(user.status! == '1'){ %>
								selected="selected"
							<% } %>
						>正常</option>
					</select>
				</div>
				<span style="color:red">*必填项</span>
				<% } %>	
				<% } %>
				
			</div>
			</form>
			<!-- <div style="margin-bottom: 20px">
				<label class="label-top">详细信息:</label>
				<a href="#" class="easyui-linkbutton button-blue button-sm" onclick="intoPersonnel();">
					<i id="intoPersonnel"class="fa fa-check"></i> 点击设置
				</a>
			</div>
			<div style="margin-bottom: 20px">
				<label class="label-top">员工离职:</label>
				<a href="#" class="easyui-linkbutton button-blue button-sm" onclick="outPersonnel();">
					<i id="outPersonnel"class="fa fa-check"></i> 点击设置
				</a>
			</div> -->
		</div>
	</div>
	<div id="menuContent" class="menuContent" style="display: none; position: absolute;">
		<ul id="treeDemo" class="ztree" style="margin-top: 0;width: 218px;"></ul>
	</div>
	<script type = "text/javascript">
	function DisplayAndHiddenBtn() {
	
		var  status=$("#status").val();
	
	    var intoPersonnel = document.getElementById(intoPersonnel);
	    var outPersonnel = document.getElementById(outPersonnel);
	    
	    if (status == "0") {
	    	outPersonnel.style.display = "block"; //style中的display属性
	    	intoPersonnel.style.display = "none";
	    }
	    else if (status == "1") {
	    	outPersonnel.style.display = "none";
	    	intoPersonnel.style.display = "block";
	    }
	}
</script>

	<script type="text/javascript">
	function intoPersonnel() {
		
		loadDialog(null, null, '设置详细信息', '${cxt !}/intoPersonnel?personnelIds=' + "${user.ids! }",null,550);

	}
	function outPersonnel() {
		
		loadDialog(null, null, '员工离职', '${cxt !}/outPersonnel?personnelIds=' + "${user.ids! }",null,550);

	}
		//@ sourceURL=mmm.js
		var $form = $('#addDept');

		var submitNow = function($dialog, $grid, $tree, $pjq) {
			var url = "${cxt!}/departmentUser/upUser";
			$.post(url, sy.serializeObject($form), function(result) {
				if (result.code == '200') {
					$grid.datagrid('reload');
					$.slideMsg("修改成功！", $pjq);
					$dialog.dialog('destroy');
				} else {
					$.alert($pjq, result.msg);
				}
			}, 'json');
		};
		var submitForm = function($dialog, $grid, $tree, $pjq) {
			submitNow($dialog, $grid, $tree, $pjq);
			// 					$form.isValid(function(isValied){
			// 						if(isValied){
			// 							submitNow($dialog, $grid, $pjq);
			// 						}
			// 					});
		};

		var setting = {
			async : {
				enable : true,
				url : '${cxt!}/departmentUser/setStation',
				autoParam : [ "id=ids" ],//, "name=n", "level=lv"
				type : "post"
			},
			view : {
				dblClickExpand : false
			},
			data : {
				simpleData : {
					enable : true
				}
			},
			callback : {
				onClick : onClick
			}
		};

		function onClick(e, treeId, treeNode) {
			var zTree = $.fn.zTree.getZTreeObj("treeDemo"), nodes = zTree
					.getSelectedNodes(), v = "";
			nodes.sort(function compare(a, b) {
				return a.id - b.id;
			});
			for (var i = 0, l = nodes.length; i < l; i++) {
				v += nodes[i].name + ",";
			}
			if (v.length > 0)
				v = v.substring(0, v.length - 1);
			var cityObj = $("#citySel");
			cityObj.attr("value", v);
			$("#stationids").attr("value", treeNode.id);
		}
		function showMenu() {
			var cityObj = $("#citySel");
			var cityOffset = $("#citySel").offset();
			$("#menuContent").css({
				left : cityOffset.left + "px",
				top : cityOffset.top + cityObj.outerHeight() + "px"
			}).slideDown("fast");

			$("body").bind("mousedown", onBodyDown);
		}
		function hideMenu() {
			$("#menuContent").fadeOut("fast");
			$("body").unbind("mousedown", onBodyDown);
		}
		function onBodyDown(event) {
			if (!(event.target.id == "menuBtn"
					|| event.target.id == "menuContent" || $(event.target)
					.parents("#menuContent").length > 0)) {
				hideMenu();
			}
		}
		$.fn.zTree.init($("#treeDemo"), setting);
	</script>
</body>
</html>